package com.dzk.cp.c11x5.action;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.dzk.cp.c11x5.pojo.R5;
import com.dzk.cp.c11x5.util.SpringBeanUtils;
import com.dzk.cp.util.DateUtils;

@Controller("qnAction")
@Scope("prototype")
public class QnAction extends BaseAction {
	
	private static final long serialVersionUID = -4351183131937592928L;
	
	private String fromDate;
	
	private String toDate;
	
	private List<List<Integer>> codeList;
	
	public String execute() {
		if (fromDate == null || toDate == null) {
			fromDate = DateUtils.dateToStr(new Date());
			toDate = fromDate;
		}
		List<? extends R5> r5s = SpringBeanUtils.getR5Service(code).query(fromDate, toDate);
		if (r5s != null && r5s.size() > 0) {
			codeList = new ArrayList<List<Integer>>();
			for (R5 r5 : r5s) {
				List<Integer> nos = new ArrayList<Integer>();
				nos.add(r5.getN1());
				nos.add(r5.getN2());
				nos.add(r5.getN3());
				nos.add(r5.getN4());
				nos.add(r5.getN5());
				codeList.add(nos);
			}
		}
		return "success";
	}

	public String getFromDate() {
		return fromDate;
	}

	public void setFromDate(String fromDate) {
		this.fromDate = fromDate;
	}

	public String getToDate() {
		return toDate;
	}

	public void setToDate(String toDate) {
		this.toDate = toDate;
	}

	public List<List<Integer>> getCodeList() {
		return codeList;
	}

	public void setCodeList(List<List<Integer>> codeList) {
		this.codeList = codeList;
	}

}
